import Vue from "vue";
import VueRouter from "vue-router";
import NoFound from "@/pages/NoFound.vue";
import Home from "@/pages/Home.vue";
import GoodsList from "@/pages/GoodsList.vue";
import One from "@/pages/One.vue";
import My from "@/pages/My.vue";
import NewsList from "@/pages/NewsList.vue";
import Two from "@/pages/Two.vue";
import Three from "@/pages/Three.vue";

Vue.use(VueRouter);// 负责提供路由的组件以及属性。
const router = new VueRouter({
	// 注意1：如果设置了相同的路由地址，只会将第一个匹配的路由作为渲染的路由
	// 注意2：路由地址是不区别大小写的
	routes:[
		{
			// 当其它路由地址不满足时，该路由生效。
			path:"*",
			component:NoFound
		},
		{
			// 当请求资源地址为/,那么渲染的路由组件为Home
			path:"/",
			name:"home",
			component:Home
		},{
			path:"/goodsList",
			alias:"/g",// 指定地址别名
			name:"goods",
			component:GoodsList
		},{
			path:"/my",
			component:My,// 相当于：components:{default:My}
		},
		{
			path:"/my",
			name:"my",
			component:One
		},
		{
			path:"/my/a",
			component:Two
		},
		{
			path:"/newsList",
			name:"news",
			alias:["/one","/two","/three"],// 指定多个地址别名
			component:NewsList
		},{
			// 当你请求的地址为/home,那么会帮你重定向至地址为/的路由
			path:"/home",
			redirect:"/",// 重定向地址
		},
		{
			// 单页面多路由
			path:"/more",
			components:{
				One,
				Two,
				default:Three
			}
		}

	],
	// 路由模式:history与hash("默认“)
	mode:"history",
	// 基础地址，为所有的请求地址统一增加了一个前缀
	// base:"m"
});
export default router;